using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class Loading : MonoBehaviour
{
	private AsyncOperation asyncOperation;

	[SerializeField]
	private Image fillBar;

	[SerializeField]
	private float loadingTime;

	private IEnumerator Start()
	{
		float deltaTime = loadingTime / 100f;
		WaitForSeconds waitForSeconds = new WaitForSeconds(deltaTime);
		asyncOperation = SceneManager.LoadSceneAsync("Game");
		asyncOperation.allowSceneActivation = false;
		for (int i = 0; i < 101; i++)
		{
			fillBar.fillAmount = (float)i / 100f;
			yield return waitForSeconds;
		}
		asyncOperation.allowSceneActivation = true;
	}
}
